<!--  -->
<template>
  <div class="" />
</template>

<script>
import md5 from 'js-md5'
export default {
  components: {},
  props: {},
  data() {
    return {
      param: null,
      loginForm: {
        userCode: 'Test0001',
        passWord: md5('123456')
      }
    }
  },
  computed: {},
  watch: {},
  created() {
    this.url = window.location.href

    this.getUrlParams(this.url)
  },
  mounted() {

  },
  beforeCreate() {},
  beforeMount() {},
  beforeUpdate() {},
  updated() {},
  beforeDestroy() {},
  destroyed() {},
  activated() {},
  methods: {
    async goto() {
      //
      // this.user = this.$route.params.user
      // this.areaCode = this.$route.params.areaCode
      //
      await this.$store.dispatch('user/truelogin', this.loginForm).then(function() {

      }).catch(() => {

      })
      this.$router.push({
        path: this.param.url
      })
    },
    getUrlParams(url) {
      // 通过 ? 分割获取后面的参数字符串
      const urlStr = url.split('?')[1]
      // 创建空对象存储参数
      const obj = {}
      // 再通过 & 将每一个参数单独分割出来
      const paramsArr = urlStr.split('&')
      for (let i = 0, len = paramsArr.length; i < len; i++) {
        // 再通过 = 将每一个参数分割为 key:value 的形式
        const arr = paramsArr[i].split('=')
        obj[arr[0]] = arr[1]
      }
      // return obj
      this.param = obj

      this.param.url = decodeURIComponent(this.param.url)
      if (this.param.token === 'e10adc3949ba59abbe56e057f20f883e') {
        this.goto()
      } else {
        this.$router.push({
          path: '/login'
        })
      }
    }
  }
}
</script>
<style lang='scss' scoped>

</style>
